//index.js
//获取应用实例
const app = getApp()
const sss = require('../son/SHA-1/sha.js');
const totp = require('../son/SHA-1/totp.js');

var head_left_judge = false;
var touch_start_point = null;
var touch_end_point = null;
var box_true_array = [true, false, false];
var check_out_who = 0;
let cache_jud = false;
var num = 0;
var num_jud = true;
var charts_need_array = [];

Page({
  data: {
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),

    username: '',
    pwd: '',
    pwd2: '',
    pwd3: '',
    sid: "",

    animation1: {},
    mask_fade: {},
    head_left_in: {},
    mask_hide: false,
    hid_jie: true,

    box_true: [true, false, false],
    index_page_1: {},
    index_page_2: {},
    index_page_3: {},

    progress_txt: '正在加载数据',
    count: 0, // 设置 计数器 初始为0
    countTimer: null // 设置 定时器 初始为null   progress~~~~~
  },
  //事件处理函数
  bindViewTap: function () {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  head_left_tap: function () {
    this.onLoad();
  },

  dengru: function (e) {


    wx.navigateTo({
      url: '../index/index(1)'
    })

  },

  onLoad: function () {
    var _this = this;

    if (app.globalData.userInfo) {
      this.setData({
        userInfo: app.globalData.userInfo,
        hasUserInfo: true
      })
    } else if (this.data.canIUse) {
      // 由于 getUserInfo 是网络请求，可能会在 Page.onLoad 之后才返回
      // 所以此处加入 callback 以防止这种情况
      app.userInfoReadyCallback = res => {
        this.setData({
          userInfo: res.userInfo,
          hasUserInfo: true
        })
      }
    } else {
      // 在没有 open-type=getUserInfo 版本的兼容处理
      wx.getUserInfo({
        success: res => {
          app.globalData.userInfo = res.userInfo
          this.setData({
            userInfo: res.userInfo,
            hasUserInfo: true
          })
        }
      })
    }//网络请求

  },
  getUserInfo: function (e) {
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  },

  onShow: function () {
    //掌上武大Tim
    var _this = this;
    if (app.globalData.sid != null) {
      _this.setData({
        sid: app.globalData.sid,
      })
    }
    else {
      _this.setData({
        sid: "尚未登入",
      })
    }

  },


  onReady: function () {
      if (app.globalData.sid == null && app.globalData.sid == '') {
          wx.showToast({
              title: '请登入',
          })
          wx.switchTab({
              url: 'pages/index/index(1)'
          })
      }

  },

  intoLog: function () {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },

  intoLife: function () {
    
  },
  intoCourse: function () {
    wx.navigateTo({
      url: '../Course/course'
    })
  },
    intoWifi_on_off: function () {
    wx.navigateTo({
      url: '../son/wifi/wifi'
    })
  },
  intochengji: function () {
    wx.navigateTo({
      url: '../son/Course_grade'
    })
  },
  intozhaoshu: function () {
    wx.navigateTo({
      url: '../son/lend/book'
    })
  },
  intojieyuejilu: function () {
    wx.navigateTo({
      url: '../son/lend/lend_book'
    })
  }
  

})

